home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / DTS Sample Code / Apple II Sample Code / MPW IIGS SC / SC.022.AutoLaunch / utils.c < prev   
Encoding:
C/C++ Source or Header  |  1990-05-17  |  793 b   |  52 lines  |  [TEXT/MPS ]

  1. #define BASE 10
  2.  
  3. /**********************************************************************/
  4.  
  5. /* This is too obvious to bother commenting. */
  6.  
  7. unsigned int    appendi2pstr(pstr, i)
  8. char            *pstr;
  9. unsigned int    i;
  10. {
  11.     unsigned int    j;
  12.  
  13.     j = 0;
  14.     if (i >= BASE) j = appendi2pstr(pstr, i / BASE);
  15.     pstr[++*pstr] = "0123456789ABCDEF"[i - j];
  16.     return(BASE * i);
  17. }
  18.  
  19. /**********************************************************************/
  20.  
  21. void            i2pstr(pstr, i)
  22. char            *pstr;
  23. unsigned int    i;
  24. {
  25.     *pstr = 0;
  26.     appendi2pstr(pstr, i);
  27. }
  28.  
  29. /**********************************************************************/
  30.  
  31. unsigned int    pstr2i(pstr)
  32. char            *pstr;
  33. {
  34.     unsigned int    c, i, j;
  35.  
  36.     for (i = j = 0; ++j <= *pstr;) {
  37.         c = pstr[j];
  38.         if ((c < '0') || (c > '9')) break;
  39.         i = 10 * i + c - '0';
  40.     }
  41.     return(i);
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.